//
//  GLViewController.h
//  Lesson 9
//
//  Created by wq on 11-8-26.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

typedef struct _Star {
	_Star() {
		r = 0;
		g = 0;
		b = 0;
		
		dist = 0;
		angle = 0;
	}
	
	GLubyte r;
	GLubyte g;
	GLubyte b;
	
	GLfloat dist;
	GLfloat angle;
}Star;

#define STAR_NUM 100
#define MAX_DSIT 140.f

@interface GLViewController : UIViewController {
	EAGLContext *context;
	CADisplayLink *dispLink;
	
	BOOL animating;
	NSUInteger frameInterval;
	
	GLuint textures[1];
	
	Star _stars[STAR_NUM];
	
	GLfloat _tilt;
	
	bool _twinkle;
}

@property(nonatomic, readonly) BOOL animating;
@property(nonatomic, assign) NSUInteger frameInterval;

-(void)startAnimation;
-(void)stopAnimation;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

@end
